const nunjucks = require('nunjucks');
/**
 * 循环
 */
nunjucks.configure({
    autoescape:false
});
//src must be a string or an object describing the source
let result = nunjucks.renderString(`
   <ul>
     {% for user in users %}
       <li>
       loop.index-{{loop.index}},
       loop.index0-{{loop.index0}},
       loop.revindex-{{loop.revindex}},
       loop.first-{{loop.first}},
       loop.last-{{loop.last}},
       loop.length-{{loop.length}},
       {{user.id}}:{{user.name}}
       </li>
     {% endfor %}
   </ul>
`
,{
 users:[
    {id:1,name:'zhufengjiagou1'},
    {id:2,name:'zhufengjiagou2'},
    {id:3,name:'zhufengjiagou3'}]
 }
);
console.log(result);